<template>
    <div class="newinfo-contain">
        <div class="newinfo-title">{{ newsinfo.title }}</div>
        <div class="newinfo-list">
            <span>发表时间：{{ newsinfo.add_time | dateFormat }}</span>
            <span>点击：{{ newsinfo.click }}次</span>
        </div>
        <hr>
        <div class="newinfo-content" v-html="newsinfo.content"></div>
        <comment-box v-bind:parentsData="id"></comment-box>
    </div>
</template>


<script>
    import {Toast} from "mint-ui";
    import comment from '../subcomponents/comment.vue';

    export default {
        data() {
            return {
                id: this.$route.params.id,
                newsinfo: {}
            }
        },
        created() {
            this.getnewsinfo();
        },
        methods: {
            getnewsinfo() {
                this.$http.get("api/getnew/" + this.id).then(result => {
                    if (result.body.status === 0) {
                        this.newsinfo = result.body.message[0];
                    } else {
                        Toast("信息获取失败。。。。");
                    }
                })
            }
        },
        components: {
            'comment-box': comment
        }
    }
</script>


<style lang='scss'>
    .newinfo-contain {
        padding: 0 4px;
        .newinfo-title {
            font-size: 16px;
            color: red;
            text-align: center;
            margin: 15px;
        }
        .newinfo-list {
            color: darkslateblue;
            display: flex;
            justify-content: space-between;
            font-size: 13px;
        }
        .newinfo-content {
            img {
                width: 100%;
            }
        }
    }
</style>